//
//  HZBasisViewController.swift
//  HansWeibo
//
//  Created by Hans on 16/8/9.
//  Copyright © 2016年 Hans. All rights reserved.
//

import UIKit

class HZBasisViewController: UIViewController {
    
    //判断用户是否登录
    let isLogin: Bool = HZUserAccountViewModel.sharedTools.isLogin
    //访客视图view
    var basisView: HZBasisView?
    
    
    override func loadView() {
        
        if isLogin {
            view = tableView
        }else {
            setupBasisView()
        }
        
    }
    
    //设置访客视图
    func setupBasisView(){
        
        setupNav()
        basisView = HZBasisView()
        //02 实例化闭包
        basisView?.bb = {
            //04
            print("按钮点击")
            self.loginAction()
        }
        
        view = basisView
    }
    
    //监听按钮点击
    func loginAction(){
        
        let oayth = HZOAythViewController()
        presentViewController(UINavigationController(rootViewController: oayth), animated: true, completion: nil)
        
    }
    
    
    // 设置导航
    func setupNav(){
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(HZBasisViewController.loginAction))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(HZBasisViewController.loginAction))
        
    }
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }

    //MARK: - 懒加载控件
    lazy var tableView: UITableView = UITableView()
    
}
